<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
import { loginApi } from '../api/index'
import { useUserStore } from '../stores/user'
const userStore = useUserStore()
const loginInfo = reactive({
    loginname: '',
    password: ''
})
const loginClick = async () => {
    const dict = { 'loginname': loginInfo.loginname, 'password': loginInfo.password }
    const res = await loginApi(dict)
    router.push('/')
    userStore.login(loginInfo.loginname, loginInfo.password)
}
</script>
<template>
    <n-card style="width:400px;height: 200px;">
        <n-space data-tauri-drag-region vertical align="center">
            <div data-tauri-drag-region>测试是否可拖拽</div>
            <n-input v-model:value="loginInfo.loginname" placeholder="输入账号/邮箱"></n-input>
            <n-input v-model:value="loginInfo.password" placeholder="输入密码" type="password"></n-input>
            <n-button type="primary" @click="loginClick" size="medium">登录</n-button>
            <n-button text type="primary">没有账号?注册 </n-button>
        </n-space> </n-card>
</template>
<style scoped></style>